<%@page language="java" import="java.net.*,java.io.*" pageEncoding="gb2312"%>

<% response.reset();
response.setContentType("application/x-downloaddfdfdfdfdfdfdfdfd");
System.out.println(this.getClass().getClassLoader()
.getResource("/").getPath());
String filenamedownload = "c:\\uploads\\" + request.getParameter("filename");
System.out.println(request.getParameter("filename"));
String filenamedisplay = request.getParameter("filename");
filenamedisplay = URLEncoder.encode(filenamedisplay, "UTF-8");
response.addHeader("Content-Disposition", "attachment;filename="
+ filenamedisplay);
OutputStream output = null;
FileInputStream fis = null;
try {
output = response.getOutputStream();
fis = new FileInputStream(filenamedownload);
byte[] b = new byte[1024];
int i = 0;
while ((i = fis.read(b)) > 0) {
output.write(b, 0, i);
}
output.flush();
} catch (Exception e) {
System.out.println("Error!");
e.printStackTrace();
} finally {
if (fis != null) {
fis.close();
fis = null;
}
if (output != null) {
output.close();
output = null;
}
}

%>